//
//  SCHomeClassifyCell.m
//  shangcheng
//
//  Created by Jie Jie on 2019/6/14.
//  Copyright © 2019 张艳江. All rights reserved.
//

#import "SCHomeClassifyCell.h"

CGFloat const k_classify_tb_space = 10;

@interface SCHomeClassifyCell()

@property (nonatomic , strong) UIImageView *classify_img;
@property (nonatomic , strong) UILabel *classify_name_label;

@end

@implementation SCHomeClassifyCell

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self.contentView addSubview:self.classify_img];
        [self.contentView addSubview:self.classify_name_label];
        [self add_masonry];
        
    }
    return self;
}

-(void)add_masonry{
    
    CGFloat width = 40;
    CGFloat space = (kScreenW / 4 - width) / 2;
    
    [self.classify_img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(k_classify_tb_space);
        make.left.mas_equalTo(space);
        make.width.and.height.mas_equalTo(width);
        
    }];
    
    [self.classify_name_label mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.classify_img.mas_bottom);
        make.left.and.right.and.bottom.mas_equalTo(0);
       
    }];
    
}

-(void)setClassify_model:(SCHomeClassifyModel *)classify_model{
    
    _classify_model = classify_model;
    
    self.classify_img.image = [UIImage imageNamed:classify_model.classify_img];
    self.classify_name_label.text = classify_model.classify_name;
    
}

#pragma mark get
-(UIImageView *)classify_img{
    
    if (_classify_img == nil) {
        _classify_img = [[UIImageView alloc] init];
       
    }
    return _classify_img;
}

-(UILabel *)classify_name_label{
    
    if (_classify_name_label == nil) {
        _classify_name_label = [[UILabel alloc] init];
        _classify_name_label.text = @"分类";
        _classify_name_label.font = [UIFont systemFontOfSize:12.0f];
        _classify_name_label.textColor = RGB(142, 142, 142);
        _classify_name_label.textAlignment = NSTextAlignmentCenter;
    }
    return _classify_name_label;
}


@end
